/**
 * 
 */
package ext.ux.files.client;

import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

import ext.ux.files.client.dialog.model.Favorite;
import ext.ux.files.client.dialog.model.FileModel;
import ext.ux.files.client.dialog.ui.OpenDialog;

/**
 * Just a simple entry point to test widgets
 * 
 * @author Eric Taix
 */
public class Files implements EntryPoint {

  private OpenDialog dialog = new OpenDialog();

  public void onModuleLoad() {
    Viewport viewport = new Viewport();
    viewport.setLayout(new FitLayout());
    ContentPanel panel = new ContentPanel();
    panel.setHeaderVisible(false);
    viewport.add(panel);
    
    dialog.addFavorite(new Favorite("Computer", new FileModel(), "icon-computer"));
    dialog.addFavorite(new Favorite("Network", new FileModel(), "icon-network"));
    FileModel fileModel = new FileModel();
    fileModel.setDirectory(true);
    fileModel.setAbsoluteName("\\PROJECTS");
    dialog.addFavorite(new Favorite("Projects", fileModel, "icon-favorite"));

    
    panel.add(new Button("show OpenDialog", new SelectionListener<ComponentEvent>() {

      @Override
      public void componentSelected(ComponentEvent ceP) {
        dialog.show();
      }

    }));

    RootPanel.get().add(viewport);
  }

}